﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TelerikAcademyOopProject
{
    class StockProjectAgentMain
    {

        public static void help()
        {
            // set some fancy color
            Console.ForegroundColor = ConsoleColor.Green;

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("|-------------------------------------------------------------------------|");
            sb.AppendLine("|------------------------------HELP YUNG STOCKERS------------------------ |");
            sb.AppendLine("|-------------------------------------------------------------------------|");
            sb.AppendLine("Avaliable comands:");
            sb.AppendLine("buy               : Buy some product ");
            sb.AppendLine("stack             : Show all bout items");
            sb.AppendLine("items/stocks/goods: Show a list of all avalabel Items in general or by type");
            sb.AppendLine("deposit           : Deposit money on the stock agent");
            sb.AppendLine("show-money        : Show stock agent Balance");
            sb.AppendLine("add-item          : Add new Item to the stock stack ");
            sb.AppendLine("exit              : Exit from the sustems");
            sb.AppendLine("help              : You know what thah mean right!!!");
            Console.WriteLine(sb.ToString());

            // reset this fancy color;
            Console.ResetColor();
        }

        public static void exit()
        {

            Console.WriteLine("See you soon");
        }

        static void Main(string[] args)
        {

            StockManager sm = new StockManager();

            /** SET Some Setup DataBase */
            sm.AddItem("Stock", "#10", "Google",    new Spred(1.4M, 1.5M), 100);
            sm.AddItem("Stock", "#15", "Microsoft", new Spred(1.5M, 1.5M), 100);
            sm.AddItem("Stock", "#14", "NVidia",    new Spred(1.9M, 2.5M), 100);
            sm.AddItem("Stock", "#21", "Ubisoft",   new Spred(1.2M, 1.2M), 100);
            sm.AddItem("Stock", "#94", "IBM",       new Spred(1.5M, 1.6M), 100);
            sm.AddItem("Stock", "#02", "Apple",     new Spred(2.9M, 3.4M), 100);
            sm.AddItem("Stock", "#04", "Samsung",   new Spred(1.0M, 1.0M), 100);
            sm.AddItem("Stock", "#55", "Telerik",   new Spred(1.6M, 1.7M), 100);
            sm.AddItem("Stock", "#95", "Nokia",     new Spred(0.9M, 1.0M), 100);

            
            Buyer player_b = new Buyer();
            player_b.setTraderProperties("#11", "Todor Nenchov", "test", new Account(), sm);

            Seller player_s = new Seller();
            player_s.setTraderProperties("#100", "Todor Penchov", "test", new Account(), sm);



            while (true)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write("Stock Terminal type command/help: ");
                Console.ResetColor();

                string command = Console.ReadLine();

                switch (command)
                {
                    /* TRADER COMAND */

                    case "buy":
                        Console.WriteLine("Enter Stock ID:");
                        string stockId = Console.ReadLine();

                        player_b.BuyItem(stockId);
                        break;

                    case "stack":
                        player_b.showItemStack();
                        break;

                    case "deposit":
                        decimal d = decimal.Parse(Console.ReadLine());
                        player_b.Deposit(d);
                        break;

                    case "show-money":
                        Console.WriteLine(player_b.TraderAccount.Balance);
                        break;


                    /* ITEM COMANDS*/
                    case "items":
                        sm.showItems();
                        break;

                    case "stocks":
                        sm.showStocks();
                        break;

                    case "goods":
                        sm.showGoods();
                        break;

                    /* ADMINISTRATION COMMANDS*/

                    case "add-item":
                        sm.setNewItem();
                        break;

                    case "help":
                        help();
                        break;

                    default:
                        Console.WriteLine("The comand {0} is not recognised for more info about avalible comands type help", command);
                        break;
                }

            }
        
        
        }
        }
    }
